import os
import subprocess

def capture_screen():
    screenshot_path = "screen.png"
    result = subprocess.run(
        ["adb", "exec-out", "screencap", "-p"],
        stdout=open(screenshot_path, "wb")
    )
    if result.returncode == 0:
        print(f"屏幕截图已保存到 {screenshot_path}")
    else:
        print("屏幕截图失败")

capture_screen()